<?php 

/**
 * JoiGallery - image gallery component for Joostina
 *
 * Шаблон вывода страницы добавления/редактирования категории
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	View
 * @filename default.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/
defined('_VALID_MOS') or die();

//Подключаем CSS-файл шаблона
//$mainframe->addCSS(JPATH_SITE.'/components/com_joigallery/view/css/default.css');
?>

<?php if(!$cat->id && !$params->_access->allow_me('add_cat', $my->gid) ){?>
        <div class="error"><?php echo $params->_access->error('add_cat'); ?></div>
<?php return ; } ?>

<?php if($cat->id && !$params->_access->allow_me('edit_cat', $my->gid)){?>
        <div class="error"><?php echo $params->_access->error('edit_cat'); ?></div>
<?php return ; } ?>

<div class="joi_gallery">
  <div class="joi_gallery_editcategory">

    <?php
    if ($params->cat_add_edit_pathway)
         echo '<div class="joi_gallery_pathway">'.mosPathWay().'</div>';    
    ?>

    <div class="componentheading">
      <div class="buttons fr">
        <span class="button">
          <a class="button apply_cat" href="javascript: void(0);" ><?php echo _APPLY?></a>
        </span>
        <span class="button">
          <a class="button save_cat" href="javascript: void(0);" ><?php echo _SAVE?></a>
        </span>
        <span class="button">
          <a class="button cancel_cat" href="javascript: void(0);" ><?php echo _CANCEL?></a>
        </span>
      </div>
      <?php
      if ($params->cat_add_edit_title) { ?>
          <h1><?php echo $cat->id ? _C_JOIGALLERY_CATEGORY_EDIT : _C_JOIGALLERY_CATEGORY_ADD;?></h1>
      <?php } ?>
    </div>
    <div class="clrpx">&nbsp;</div>

    <form action="<?php echo sefRelToAbs('index.php')?>"
          method="post"
          id="cat_form"
          class="cat_form" name="cat_form" enctype="multipart/form-data">
      
      <table class="adminform" width="100%" cellpadding="0" cellspacing="0">
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>
		<tr>
          <td id="name_txt" width="150">
            <?php echo _C_JOIGALLERY_CATEGORY_NAME; ?>:
          </td>
          <td>
            <input class="inputbox" type="text" id="name" name="name" value="<?php echo stripslashes( $cat->name ); ?>" size="50" maxlength="255" title="A long name to be displayed in headings" />
          </td>
        </tr>
        <tr>
          <td id="title_txt">
            <?php echo _C_JOIGALLERY_ALIAS; ?>:
          </td>
          <td>
            <input class="inputbox" type="text" id="title" name="title" value="<?php echo stripslashes( $cat->title ); ?>" size="50" maxlength="50" title="A short name to appear in menus" />
          </td>
        </tr>        
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td>
            <?php echo _C_JOIGALLERY_CATEGORY_PARENT; ?>:
          </td>
          <td>
            <?php echo mosHTML::selectList($cat->catlist, 'parent_id', 'class="inputbox" size="1"', 'id', 'name', $cat->parent_id); ?>
          </td>
        </tr>
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td>
            <?php echo _C_JOIGALLERY_PUBLISHED; ?>:
          </td>
          <td>
            <?php echo mosHTML::yesnoRadioList('published', '', intval($cat->published)); ?>
          </td>
        </tr>
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td valign="top">
            <?php echo _C_JOIGALLERY_DESCRIPTION; ?>:
          </td>
          <td>
            <?php editorArea( 'editor1',  $cat->description , 'description', '100%;', '300', '60', '20', $wwig_params ) ; ?>
          </td>
        </tr>
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>        
        <tr>
         <td>&nbsp;</td>
         <td>
          <div class="buttons">
			<div class="buttons">
				<span class="button">
					<a class="button apply_cat" href="javascript: void(0);" ><?php echo _APPLY?></a>
				</span>
				<span class="button">
					<a class="button save_cat" href="javascript: void(0);" ><?php echo _SAVE?></a>
				</span>
				<span class="button">
					<a class="button cancel_cat" href="javascript: void(0);" ><?php echo _CANCEL?></a>
				</span>
			</div>
         </td>
        </tr>
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>
      </table>

      <input type="hidden" name="Itemid" value="<?php echo $params->_Itemid; ?>" />
      <input type="hidden" name="id" value="<?php echo $cat->id; ?>" />
      <input type="hidden" name="option" value="<?php echo $params->_option; ?>" />
      <input type="hidden" name="task" id="task" value="" />
      <input type="hidden" name="act" value="categories" />

    </form>

  </div>
</div>

<script language="javascript" type="text/javascript">
  //Проверка формы 
    $('#cat_form').submit(function() {
        if (!$('#name').val()) {			
			alert("<?php echo _C_JOIGALLERY_MSG_CATEGORY_NO_NAME; ?>");
			$('#name_txt').css("color", "red");
			return false;
		}
		else if (!$('#title').val()) {
			alert("<?php echo _C_JOIGALLERY_MSG_CATEGORY_NO_TITLE; ?>");
			$('#title_txt').css("color", "red");
			return false;
		}
    });
</script>